<template>
	<view>
		<view class="headerbox">
			<view class="infobox">
				<view class="headpic" v-if="token">
					<image :src="info.avatar"></image>
				</view>
				<view class="headpic" v-else @click="tologin()">
					<image src="../../static/person2.png"></image>
				</view>
				<view class="titlebox" v-if="token">
					<view>{{info.nickname}}</view>
					<view class="phonebox">{{info.mobile}}</view>
				</view>
				<view class="titlebox" v-else @click="tologin()">
					<view>请登录</view>
					<!-- <view class="phonebox">{{info.mobile}}</view> -->
				</view>
				<view class="messagebox">
					<view class="msg" @click="tomsg()">
						<image src="../../static/msg.png"></image>
						<view class="dian" v-if="info.is_see==0"></view>
					</view>
				</view>
			</view>
			<!-- <view class="awordbox">
				<view class="abox">参与奖:</view>
				<view class="pricebox">￥<text style="font-size: 38rpx;font-weight: 500;">{{info.money}}</text></view>
			</view> -->
		</view>
		<view class="catebox">
			<view class="cateitem" v-for="(item,index) in contentList" :key="index" @click="clickcate(index,item)">
				<view class="leftbox">
					<image :src="item.img"></image>
					<view>{{item.text}}</view>
				</view>
				<view class="rightbox">
					<image src="../../static/right.png"></image>
				</view>
			</view>
		</view>
		<!-- <view  v-if="token" class="my-logout">
		  <view class="logout-btn" @click="handleLogout()">
		    <text>退出登录</text>
		  </view>
		</view> -->
		<!-- <view class="homebox" @click="tohome()">
			<image src="../../static/home.png"></image>
		</view> -->
		<view class="codebox" v-show="codebox">
			<view class="service">
				<view class="closenbox" @click="codebox = false">
					<image src="../../static/closen.png"></image>
				</view>
				<view class="codetit">
					<image src="../../static/person.png"></image>
					<view>客服微信</view>
				</view>
				<view class="codeword">扫码添加客服微信</view>
				<view class="QRbox">
					<view class="imgcode">
						<image src="../../static/coed.png"></image>
					</view>
				</view>
			</view>
			<!-- <image class="imgbox" src="../../static/tit.png"></image> -->
			
		</view>
		<image @click="towebview()" style="width: 100%;position: absolute;bottom: 10rpx;" mode="widthFix" src="http://gw.app65.cn/uploads/images/copyright.png"></image> 
	</view>
</template>

<script>
	export default {
		data() {
			return {
				contentList: [{
						img: "../../static/content@1.png",
						text: "抽奖记录",
						path:'/pages/rafflerecord/rafflerecord'
					}, {
						img: "../../static/aword.png",
						text: "大转盘抽奖",
						path:'/pages/luck_draw/luck_draw'
					},
					// {
					// 	img: "../../static/content@2.png",
					// 	text: "联系客服"
					// }, 
					// {
					// 	img: "../../static/content@3.png",
					// 	text: "反馈记录",
					// 	path:'/pages/feedbackrecord/feedbackrecord'
					// }
				],
				codebox:false,//客服二维码弹窗
				info:{},
				token:uni.getStorageSync('token')
			};
		},
		onLoad() {
			this.getinfo()
		},
		methods:{
			//功能跳转
			clickcate(index,item){
				if(index==2){
					this.codebox = true
				}else{
					uni.navigateTo({
						url:item.path
					})
				}
			},
			//回首页
			tohome(){
				uni.reLaunch({
					url:'/pages/index/index'
				})
			},
			getinfo(){
				this.$http({
					url:'api/Answer/user_info',
					data:{
						token:uni.getStorageSync('token')
					}
				}).then(res=>{
					this.info = res.data
				})
			},
			//消息
			tomsg(){
				uni.navigateTo({
					url:'/pages/message/message'
				})
			},
			//去登录
			tologin(){
				uni.reLaunch({
					url:'/pages/login/login'
				})
			},
			// 退出登录
			   handleLogout() {
			    uni.showModal({
			      title: '友情提示',
			      content: '是否清除缓存?',
			      success:(res)=> {
			        if (res.confirm) {
			      uni.clearStorage()
			      uni.reLaunch({
			       url: '/pages/index/index'
			      });
			        }
			      }
			    })
			    
			   },
			   towebview(){
						uni.navigateTo({
							url:'/pages/webview/webview'
						})
					},
		}
	}
</script>

<style lang="scss" scoped>
	.headerbox{
		background: url(http://wjdc.zxkjnc.com/images/bg.png) no-repeat;
		width: 100%;
		height:324rpx;
		background-size:100% 324rpx;
		.infobox{
			display:flex;
			align-items: center;
			padding-top: 70rpx;
			.headpic{
				width: 20%;
				text-align: center;
				image{
					width: 110rpx;
					height: 110rpx;
					border-radius: 100%;
				}
			}
			.titlebox{
				width: 70%;
				font-size: 36rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: #FFFFFF;
				.phonebox{
					font-size: 24rpx;
				}
			}
			.messagebox{
				text-align: center;
				.msg{
					width: 62rpx;
					height: 62rpx;
					border-radius: 100%;
					background-color: #1e7bb5;
					margin-top: -30rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					position: relative;
					image{
						width: 35rpx;
						height: 35rpx;
					}
					.dian{
						width: 10rpx;
						height: 10rpx;
						border-radius: 100%;
						background-color: red;
						position: absolute;
						right: 0;
						margin-top: -20rpx;
						z-index: 9;
					}
				}
			}
		}
		.awordbox{
			display: flex;
			align-items: center;
			margin-top: 35rpx;
			font-size: 26rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FFFFFF;
			.abox{
				margin-left: 40rpx;
			}
			.pricebox{
				width: fit-content;
				height: 60rpx;
				background: linear-gradient(90deg, #83c0ed 0%, rgba(80,145,243,0) 100%);
				border-radius: 30rpx;
				padding: 0 15rpx;
				line-height: 60rpx;
				margin: 0 10rpx;
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #FFFFFF;
			}
		}
	}
	.catebox{
		margin-top: 40rpx;
		.cateitem{
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 110rpx;
			background: linear-gradient(90deg, #CAE4FF, #FFFFFF);
			border-radius: 20rpx;
			width: 90%;
			margin: 0 auto 20rpx auto;
			.leftbox{
				display: flex;
				align-items: center;
				font-size: 30rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				color: #222222;
				image{
					width: 76rpx;
					height: 76rpx;
					margin: 0 25rpx;
				}
			}
			.rightbox{
				image{
					width: 11rpx;
					height: 20rpx;
					margin-right: 25rpx;
				}
			}
		}
	}
	.codebox{
		position: absolute;
		width: 489rpx;
		// height: 547rpx;
		// background: #FFFFFF;
		// box-shadow: 0rpx 9rpx 27rpx 0rpx rgba(80,145,243,0.46);
		background: url(http://wjdc.zxkjnc.com/images/kefu.png) no-repeat;
		background-size: 489rpx 656rpx;
		border-radius: 10rpx;
		left: 50%;
		transform: translate(-50%,0);
		z-index: 2;
		top: 252rpx;
		.service{
			width: 489rpx;
			height: 656rpx;
			// background-color: #FFF;
			
			// background: url(http://wjdc.zxkjnc.com/images/kefu.png) no-repeat;
			// background-size: 489rpx 656rpx;
			.closenbox{
				text-align: right;
				padding-top: 10rpx;
				margin: 0rpx 10rpx 0 0 ;
				image{
					width: 36rpx;
					height: 36rpx;
				}
			}
			.codetit{
				display: flex;
				align-items: center;
				justify-content: center;
				image{
					width: 47rpx;
					height: 47rpx;
					margin-right: 20rpx;
				}
			}
			.codeword{
				text-align: center;
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				color: #555555;
				margin-top: 40rpx;
			}
			.QRbox{
				width: 396rpx;
				height: 365rpx;
				margin: 50rpx auto 0 auto;
				background-color: #FFF;
				display: flex;
				justify-content: center;
				align-items: center;
				.imgcode{
					width: 300rpx;
					height: 300rpx;
					// background: url(http://wjdc.zxkjnc.com/images/bg.png) no-repeat;
					// background-size: 300rpx 300rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					image{
						width: 262rpx;
						height: 262rpx;
					}
				}
				
			}
			// border-radius: 10rpx 10rpx 0 0;
		}
		.imgbox{
			width: 396rpx;
			height: 28rpx;
		}
		
	}
	.homebox{
		position: absolute;
		z-index: 9;
		bottom: 200rpx;
		right: 30rpx;
		image{
			width: 97rpx;
			height: 97rpx;
		}
	}
	// 退出登录
	.my-logout {
	  display: flex;
	  justify-content: center;
	  padding: 50rpx;
	
	  .logout-btn {
	    width: 60%;
	    margin: 0 auto;
	    font-size: 28rpx;
	    color: #616161;
	    border-radius: 20rpx;
	    border: 1px solid #dcdcdc;
	    padding: 16rpx 0;
	    text-align: center;
	  }
	}
</style>
